package com.sugon.task;


import com.sugon.annotation.ShiroSecurityManagerChecker;
import com.sugon.dao.SysMsgDao;
import com.sugon.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 系统消息处理定时任务
 *
 * @author YuXD
 * @since 2021-12-15
 */
@Slf4j
@Component("sysMessageProcessTask")
public class SysMessageProcessTask extends AbstractBaseProcessTask {

    @Autowired
    private SysConfigService configService;
    @Autowired
    private SysMsgDao msgDao;

    @ShiroSecurityManagerChecker
    @Override
    public void process() {
        // 只保留消息有效期内的系统消息
        Integer validDuration = configService.getSysMsgValidDuration();
        msgDao.batchDelete("start_date + " + validDuration + " < sysdate");
    }

}
